home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $DefineSwitch < prev    next >
Encoding:
Text File  |  1993-04-09  |  954 b   |  40 lines  |  [TEXT/KEEN]

  1. #$DefineSwitch
  2. #Select a bunch of defines, and run Hawk on the front selection
  3. #Leave "Show std out" and "Select all of stdout" checked
  4.  
  5. { for (k = 1; k <= NF; k++)
  6.     {
  7.     if ($k ~ /define/)
  8.         {
  9.         if ($(k+1) !~ /.*\(.*/ )
  10.             case[++i] = $(k+1)
  11.         break
  12.         }
  13.     }
  14. }
  15.  
  16. END    {    print "switch (??)"
  17.         print "\t{"
  18.         for (k = 1; k <= i; ++k)
  19.             {
  20.             print "case " case[k] ":"
  21.             print "\t"
  22.             print "break;"
  23.             }
  24.         print "default:"
  25.         print "\t"
  26.         print "break;"
  27.         print "\t}"
  28.     }
  29.  
  30. # User’s Manual references:
  31. # «hAWK User’s Manual» «F   Running hAWK programs»
  32. # «hAWK User’s Manual» «L  5   Regular expressions»
  33. # «hAWK User’s Manual» «M  5   Built-in string and file functions»
  34. # «hAWK User’s Manual» «K  4   Built-in variables»
  35. # «hAWK User’s Manual» «K  8   Arrays»
  36. # «hAWK User’s Manual» «N   User-defined functions»
  37. # «hAWK User’s Manual» «P  3   The getline function»
  38. # «hAWK User’s Manual» «O  3   Output into files»
  39. # «hAWK User’s Manual» «Q   The hAWK function»
  40.